{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  \n",
    "+ 学号"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "贫困户\n",
      "需要进行住房补贴\n",
      "需要提供免费教育\n",
      "需要保障自来水\n",
      "\n",
      "贫困户\n",
      "需要进行住房补贴\n",
      "需要提供免费教育\n",
      "需要保障自来水\n",
      "需要进行健康帮扶\n",
      "\n",
      "非贫困户\n"
     ]
    }
   ],
   "source": [
    "class poverty(object):\n",
    "    def __init__(self,x1,x2,x3,x4):\n",
    "        self.house=x1\n",
    "        self.edu=x2\n",
    "        self.water=x3\n",
    "        self.health=x4\n",
    "    def arrange(self,house):\n",
    "        if house==0:\n",
    "            self.house=1\n",
    "        else:\n",
    "            self.house=0\n",
    "    def shangxue(self,edu):\n",
    "        if edu==0:\n",
    "            self.edu=1\n",
    "        else:\n",
    "            self.edu=0\n",
    "    def yinshui(self,water):\n",
    "        if water==0:\n",
    "            self.water=1\n",
    "        else:\n",
    "            self.water=0\n",
    "    def roudannai(self,protein):\n",
    "        if protein==0:\n",
    "            self.protein=1\n",
    "        else:\n",
    "            self.protein=0\n",
    "    def pinkunhu(self):\n",
    "        sum=0   \n",
    "        sum=self.house+self.edu+self.water+self.protein   \n",
    "        if sum>2:\n",
    "            print(\"\\n贫困户\") \n",
    "            if self.house==1:\n",
    "                print(\"需要进行住房补贴\")\n",
    "            if self.edu==1:\n",
    "                print(\"需要提供免费教育\")\n",
    "            if  self.water==1:\n",
    "                print(\"需要保障自来水\")\n",
    "            if  self.protein==1:\n",
    "                print(\"需要进行健康帮扶\")\n",
    "        else :\n",
    "            print(\"\\n非贫困户\")\n",
    "family1=poverty(1,0,0,1)\n",
    "family1.arrange(house=0)\n",
    "family1.shangxue(edu=0)\n",
    "family1.yinshui(water=0)\n",
    "family1.roudannai(protein=1)\n",
    "family1.pinkunhu()\n",
    "\n",
    "family2=poverty(0,1,1,1)\n",
    "family2.arrange(house=0)\n",
    "family2.shangxue(edu=0)\n",
    "family2.yinshui(water=0)\n",
    "family2.roudannai(protein=0)\n",
    "family2.pinkunhu()\n",
    "\n",
    "family3=poverty(0,1,1,0)\n",
    "family3.arrange(house=1)\n",
    "family3.shangxue(edu=1)\n",
    "family3.yinshui(water=1)\n",
    "family3.roudannai(protein=1)\n",
    "family3.pinkunhu()\n",
    "      "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "zhan BMI可能偏大\n",
      "zhou 体重正常\n"
     ]
    }
   ],
   "source": [
    "class weight():\n",
    "    def __init__(self,name,scores,sleep):\n",
    "        self.name = name\n",
    "        self.scores = scores\n",
    "        self.sleep = sleep\n",
    "    def forecast_weight(self):\n",
    "        if int(self.scores)>90 and int(self.sleep)<6:\n",
    "            print(self.name+\" BMI可能偏大\")\n",
    "        else:\n",
    "            print(self.name+\" 体重正常\")\n",
    "one_person = weight(\"liu\",91,8)\n",
    "two_person = weight(\"zhan\",94,4)\n",
    "three_person = weight(\"zhou\",82,5)\n",
    "\n",
    "two_person.forecast_weight()\n",
    "three_person.forecast_weight()\n",
    "                "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "liu体重正常\n",
      "\n",
      "\n",
      "zhan体重正常\n",
      "\n",
      "\n",
      "zhou体重正常\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "class student_information(object):\n",
    "    def __init__(self,x1,x2,x3): \n",
    "        self.name = x1\n",
    "        self.grade = x2\n",
    "        self.sleeping_time = x3\n",
    "    \n",
    "    def fat_or_thin(self,a1,a2):\n",
    "        if self.grade>a1 and self.sleeping_time<a2: \n",
    "            print(\"%sBMI可能偏大\"%self.name)\n",
    "        else :\n",
    "            print(\"%s体重正常\"%self.name)\n",
    "        \n",
    "class running_club(student_information):        \n",
    "    def __init__(self,x1,x2,x3,x4):\n",
    "        super().__init__(x1,x2,x3)\n",
    "        self.run = x4\n",
    "    \n",
    "    def new_standardization(self,a1,a2):\n",
    "        if self.grade > a1 and self.sleeping_time<a2:\n",
    "            if self.run > 30:\n",
    "                print(\"%sBMI趋向正常\"%self.name)\n",
    "            else :\n",
    "                print(\"%sBMI可能偏大\"%self.name)\n",
    "        else:\n",
    "            print(\"%s体重正常\"%self.name)\n",
    "        print(\"\\n\")\n",
    "\n",
    "\n",
    "student_1=running_club(\"liu\",90,5,35)\n",
    "student_2=running_club(\"zhan\",80,7,28)\n",
    "student_3=running_club(\"zhou\",70,4,30)\n",
    "\n",
    "student_1.new_standardization(90,6)\n",
    "student_2.new_standardization(75,6)\n",
    "student_3.new_standardization(80,4)\n",
    "    "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
